        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>WorldManifold class / box2d Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="box2d" data-type="WorldManifold">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../box2d.html">box2d</a> &rsaquo; <a href="../box2d/WorldManifold.html">WorldManifold</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>WorldManifold</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<pre class="source">
class WorldManifold {
 /**
  * World vector pointing from A to B
  */
 final vec2 normal;

 /**
  * World contact points (points of intersection)
  */
 final List&lt;vec2&gt; points;

 /**
  * Temporary Vectors that are constructed on construction. Used to prevent
  * object construction while stepping.
  */
 final vec2 pool3;
 final vec2 pool4;

 /**
  * Constructs a new WorldManifold.
  */
 WorldManifold() :
   normal = new vec2.zero(),
   pool3 = new vec2.zero(),
   pool4 = new vec2.zero(),
   points = new List&lt;vec2&gt;(Settings.MAX_MANIFOLD_POINTS) {
   for (int i = 0; i &lt; Settings.MAX_MANIFOLD_POINTS; ++i)
     points[i] = new vec2.zero();
 }

 void initialize(Manifold manifold, Transform xfA, num radiusA, Transform xfB,
     num radiusB) {
   switch (manifold.type) {
     case ManifoldType.CIRCLES:
       final vec2 pointA = pool3;
       final vec2 pointB = pool4;

       normal.x = 1.0;
       normal.y = 0.0;
       pointA.x = xfA.position.x + xfA.rotation.col0.x *
           manifold.localPoint.x + xfA.rotation.col1.x * manifold.localPoint.y;
       pointA.y = xfA.position.y + xfA.rotation.col0.y *
           manifold.localPoint.x + xfA.rotation.col1.y * manifold.localPoint.y;
       pointB.x = xfB.position.x + xfB.rotation.col0.x *
           manifold.points[0].localPoint.x + xfB.rotation.col1.x *
           manifold.points[0].localPoint.y;
       pointB.y = xfB.position.y + xfB.rotation.col0.y *
           manifold.points[0].localPoint.x + xfB.rotation.col1.y *
           manifold.points[0].localPoint.y;

       if (distance2(pointA, pointB) &gt; Settings.EPSILON * Settings.EPSILON) {
         normal.copyFrom(pointB).sub(pointA);
         normal.normalize();
       }

       final vec2 cA = normal * radiusA + pointA;
       final vec2 cB = -normal * radiusB + pointB;

       points[0].copyFrom(cA).add(cB).scale(0.5);
       return;
     case ManifoldType.FACE_A:
       final vec2 planePoint = pool3;

       normal.x = xfA.rotation.col0.x * manifold.localNormal.x +
           xfA.rotation.col1.x * manifold.localNormal.y;
       normal.y = xfA.rotation.col0.y * manifold.localNormal.x +
           xfA.rotation.col1.y * manifold.localNormal.y;
       planePoint.x = xfA.position.x + xfA.rotation.col0.x *
           manifold.localPoint.x + xfA.rotation.col1.x * manifold.localPoint.y;
       planePoint.y = xfA.position.y + xfA.rotation.col0.y *
           manifold.localPoint.x + xfA.rotation.col1.y * manifold.localPoint.y;

       final vec2 clipPoint = pool4;

       for (int i = 0; i &lt; manifold.pointCount; ++i) {
         clipPoint.x = xfB.position.x + xfB.rotation.col0.x *
             manifold.points[i].localPoint.x + xfB.rotation.col1.x *
             manifold.points[i].localPoint.y;
         clipPoint.y = xfB.position.y + xfB.rotation.col0.y *
             manifold.points[i].localPoint.x + xfB.rotation.col1.y *
             manifold.points[i].localPoint.y;

         num scalar = radiusA - ((clipPoint.x - planePoint.x) *
             normal.x + (clipPoint.y - planePoint.y) * normal.y);

         num cAx = normal.x * scalar + clipPoint.x;
         num cAy = normal.y * scalar + clipPoint.y;

         num cBx = - normal.x * radiusB + clipPoint.x;
         num cBy = - normal.y * radiusB + clipPoint.y;

         points[i].x = (cAx + cBx)*.5;
         points[i].y = (cAy + cBy)*.5;
       }

       return;
     case ManifoldType.FACE_B :
       final vec2 planePoint = pool3;

       final mat2 R = xfB.rotation;
       normal.x = R.col0.x * manifold.localNormal.x + R.col1.x *
           manifold.localNormal.y;
       normal.y = R.col0.y * manifold.localNormal.x + R.col1.y *
           manifold.localNormal.y;
       final vec2 v = manifold.localPoint;
       planePoint.x = xfB.position.x + xfB.rotation.col0.x * v.x +
           xfB.rotation.col1.x * v.y;
       planePoint.y = xfB.position.y + xfB.rotation.col0.y * v.x +
           xfB.rotation.col1.y * v.y;

       final vec2 clipPoint = pool4;

       for (int i = 0; i &lt; manifold.pointCount; ++i) {

         clipPoint.x = xfA.position.x + xfA.rotation.col0.x *
             manifold.points[i].localPoint.x + xfA.rotation.col1.x *
             manifold.points[i].localPoint.y;
         clipPoint.y = xfA.position.y + xfA.rotation.col0.y *
             manifold.points[i].localPoint.x + xfA.rotation.col1.y *
             manifold.points[i].localPoint.y;

         num scalar = radiusB - ((clipPoint.x - planePoint.x) * normal.x +
             (clipPoint.y - planePoint.y) * normal.y);

         num cBx =  normal.x * scalar + clipPoint.x;
         num cBy =  normal.y * scalar + clipPoint.y;

         num cAx = - normal.x * radiusA + clipPoint.x;
         num cAy = - normal.y * radiusA + clipPoint.y;

         points[i].x = (cAx + cBx) *.5;
         points[i].y = (cAy + cBy) *.5;
       }
       // Ensure normal points from A to B.
       normal.x = -normal.x;
       normal.y = -normal.y;
       break;
    }
 }
}
</pre>
</div>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="WorldManifold">
<button class="show-code">Code</button>
new <strong>WorldManifold</strong>() <a class="anchor-link" href="#WorldManifold"
              title="Permalink to WorldManifold.WorldManifold">#</a></h4>
<div class="doc">
<p>Constructs a new WorldManifold.</p>
<pre class="source">
WorldManifold() :
 normal = new vec2.zero(),
 pool3 = new vec2.zero(),
 pool4 = new vec2.zero(),
 points = new List&lt;vec2&gt;(Settings.MAX_MANIFOLD_POINTS) {
 for (int i = 0; i &lt; Settings.MAX_MANIFOLD_POINTS; ++i)
   points[i] = new vec2.zero();
}
</pre>
</div>
</div>
</div>
<div>
<h3>Properties</h3>
<div class="field"><h4 id="normal">
<button class="show-code">Code</button>
final <a href="../vector_math/vec2.html">vec2</a>         <strong>normal</strong> <a class="anchor-link"
            href="#normal"
            title="Permalink to WorldManifold.normal">#</a>
        </h4>
        <div class="doc">
<pre class="source">
normal
</pre>
</div>
</div>
<div class="field"><h4 id="points">
<button class="show-code">Code</button>
final List&lt;<a href="../vector_math/vec2.html">vec2</a>&gt;         <strong>points</strong> <a class="anchor-link"
            href="#points"
            title="Permalink to WorldManifold.points">#</a>
        </h4>
        <div class="doc">
<pre class="source">
points
</pre>
</div>
</div>
<div class="field"><h4 id="pool3">
<button class="show-code">Code</button>
final <a href="../vector_math/vec2.html">vec2</a>         <strong>pool3</strong> <a class="anchor-link"
            href="#pool3"
            title="Permalink to WorldManifold.pool3">#</a>
        </h4>
        <div class="doc">
<pre class="source">
pool3
</pre>
</div>
</div>
<div class="field"><h4 id="pool4">
<button class="show-code">Code</button>
final <a href="../vector_math/vec2.html">vec2</a>         <strong>pool4</strong> <a class="anchor-link"
            href="#pool4"
            title="Permalink to WorldManifold.pool4">#</a>
        </h4>
        <div class="doc">
<pre class="source">
pool4
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="initialize">
<button class="show-code">Code</button>
void <strong>initialize</strong>(<a href="../box2d/Manifold.html">Manifold</a> manifold, <a href="../box2d/Transform.html">Transform</a> xfA, num radiusA, <a href="../box2d/Transform.html">Transform</a> xfB, num radiusB) <a class="anchor-link" href="#initialize"
              title="Permalink to WorldManifold.initialize">#</a></h4>
<div class="doc">
<pre class="source">
void initialize(Manifold manifold, Transform xfA, num radiusA, Transform xfB,
   num radiusB) {
 switch (manifold.type) {
   case ManifoldType.CIRCLES:
     final vec2 pointA = pool3;
     final vec2 pointB = pool4;

     normal.x = 1.0;
     normal.y = 0.0;
     pointA.x = xfA.position.x + xfA.rotation.col0.x *
         manifold.localPoint.x + xfA.rotation.col1.x * manifold.localPoint.y;
     pointA.y = xfA.position.y + xfA.rotation.col0.y *
         manifold.localPoint.x + xfA.rotation.col1.y * manifold.localPoint.y;
     pointB.x = xfB.position.x + xfB.rotation.col0.x *
         manifold.points[0].localPoint.x + xfB.rotation.col1.x *
         manifold.points[0].localPoint.y;
     pointB.y = xfB.position.y + xfB.rotation.col0.y *
         manifold.points[0].localPoint.x + xfB.rotation.col1.y *
         manifold.points[0].localPoint.y;

     if (distance2(pointA, pointB) &gt; Settings.EPSILON * Settings.EPSILON) {
       normal.copyFrom(pointB).sub(pointA);
       normal.normalize();
     }

     final vec2 cA = normal * radiusA + pointA;
     final vec2 cB = -normal * radiusB + pointB;

     points[0].copyFrom(cA).add(cB).scale(0.5);
     return;
   case ManifoldType.FACE_A:
     final vec2 planePoint = pool3;

     normal.x = xfA.rotation.col0.x * manifold.localNormal.x +
         xfA.rotation.col1.x * manifold.localNormal.y;
     normal.y = xfA.rotation.col0.y * manifold.localNormal.x +
         xfA.rotation.col1.y * manifold.localNormal.y;
     planePoint.x = xfA.position.x + xfA.rotation.col0.x *
         manifold.localPoint.x + xfA.rotation.col1.x * manifold.localPoint.y;
     planePoint.y = xfA.position.y + xfA.rotation.col0.y *
         manifold.localPoint.x + xfA.rotation.col1.y * manifold.localPoint.y;

     final vec2 clipPoint = pool4;

     for (int i = 0; i &lt; manifold.pointCount; ++i) {
       clipPoint.x = xfB.position.x + xfB.rotation.col0.x *
           manifold.points[i].localPoint.x + xfB.rotation.col1.x *
           manifold.points[i].localPoint.y;
       clipPoint.y = xfB.position.y + xfB.rotation.col0.y *
           manifold.points[i].localPoint.x + xfB.rotation.col1.y *
           manifold.points[i].localPoint.y;

       num scalar = radiusA - ((clipPoint.x - planePoint.x) *
           normal.x + (clipPoint.y - planePoint.y) * normal.y);

       num cAx = normal.x * scalar + clipPoint.x;
       num cAy = normal.y * scalar + clipPoint.y;

       num cBx = - normal.x * radiusB + clipPoint.x;
       num cBy = - normal.y * radiusB + clipPoint.y;

       points[i].x = (cAx + cBx)*.5;
       points[i].y = (cAy + cBy)*.5;
     }

     return;
   case ManifoldType.FACE_B :
     final vec2 planePoint = pool3;

     final mat2 R = xfB.rotation;
     normal.x = R.col0.x * manifold.localNormal.x + R.col1.x *
         manifold.localNormal.y;
     normal.y = R.col0.y * manifold.localNormal.x + R.col1.y *
         manifold.localNormal.y;
     final vec2 v = manifold.localPoint;
     planePoint.x = xfB.position.x + xfB.rotation.col0.x * v.x +
         xfB.rotation.col1.x * v.y;
     planePoint.y = xfB.position.y + xfB.rotation.col0.y * v.x +
         xfB.rotation.col1.y * v.y;

     final vec2 clipPoint = pool4;

     for (int i = 0; i &lt; manifold.pointCount; ++i) {

       clipPoint.x = xfA.position.x + xfA.rotation.col0.x *
           manifold.points[i].localPoint.x + xfA.rotation.col1.x *
           manifold.points[i].localPoint.y;
       clipPoint.y = xfA.position.y + xfA.rotation.col0.y *
           manifold.points[i].localPoint.x + xfA.rotation.col1.y *
           manifold.points[i].localPoint.y;

       num scalar = radiusB - ((clipPoint.x - planePoint.x) * normal.x +
           (clipPoint.y - planePoint.y) * normal.y);

       num cBx =  normal.x * scalar + clipPoint.x;
       num cBy =  normal.y * scalar + clipPoint.y;

       num cAx = - normal.x * radiusA + clipPoint.x;
       num cAy = - normal.y * radiusA + clipPoint.y;

       points[i].x = (cAx + cBx) *.5;
       points[i].y = (cAy + cBy) *.5;
     }
     // Ensure normal points from A to B.
     normal.x = -normal.x;
     normal.y = -normal.y;
     break;
  }
}
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
